package com.sgb.knowledgeshare.viewmodel;

import androidx.lifecycle.ViewModel;

import com.sgb.knowledgeshare.ShareConfig;
import com.sgb.knowledgeshare.entity.VideoReceiveListEntity;
import com.sgb.knowledgeshare.view.activity.ShareCommentMagessActivity;
import com.swgk.core.base.api.ICallBack;
import com.swgk.core.base.model.entity.BaseEntity;
import com.swgk.core.dialog.DialogHelper;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * Created by：冯齐 on 2020/11/13 09:19
 * Description：分享-消息-评论
 */
public class ShareCommentMagessModel  extends ViewModel {
    ShareCommentMagessActivity sharecommentmagessactivity;
    public void setActivity(ShareCommentMagessActivity shareCommentMagessActivity) {
        sharecommentmagessactivity = shareCommentMagessActivity;
    }
    //获取收到的评论
    public void getVideoReceiveLists(int page) {
        Map map = new HashMap();
        map.put("pageNum",page);
        map.put("pageSize",10);
        DialogHelper.showProgressDialog(sharecommentmagessactivity, null, "加载中...", 0, true, null).setCanceledOnTouchOutside(false);
        ShareConfig.getInstance().getApi().getVideoReceiveList(map).enqueue(new ICallBack<BaseEntity<VideoReceiveListEntity>>() {
            @Override
            public void onSuccess(BaseEntity<VideoReceiveListEntity> data) {
                DialogHelper.dismissProgressDialog();
                if (data.getData() == null) {
                    return;
                }
                if (data.getState().equals(ShareConfig.RESPONSE_OK)) {
                    sharecommentmagessactivity.setVideoReceiveLists(data.getData());
                }
            }
        });
    }


}
